package com.znbf.sfbx;


import com.alibaba.fastjson2.JSONObject;

public class CallInterface {
    public static final String KEY = "www.cn-heating.com-2017-07-25";//秘钥最新
    public static void main(String[] args) {
        //String url=  "http://localhost:6025/heating/pao/shoufei_xqsflChart?niandu=2023-2024&ryid=1";
        String url = "http://localhost:6025/heating/cxf/guolufangServices/guolufangs?_type=json";
        String userId =  "402881cb50f5520e0150f9594408003b";
        String url1 = getSign(url,userId);
        System.out.println(url1);
        IndexMainReqData mIndexMainReqData = new IndexMainReqData(userId);
        JSONObject params = new JSONObject(mIndexMainReqData.toMap());
        System.out.println(params);

    }

    public static String getSign(String url , String userId){
        String reqData ="from=APP&u="+userId+"&time="+Long.toString(System.currentTimeMillis() / 1000);
        String reqSign="";
        try {
            //reqSign = MD5.MD5Encode(reqData +"&key="+KEY).toUpperCase();
            reqSign = MD5Util.encode(reqData +"&key="+KEY).toUpperCase();
        } catch (Exception e) {
            e.printStackTrace();
        }
        if(url.indexOf("?")>0){
            url += "&"+reqData+ "&sign=" + reqSign;
        }else{
            url += "?"+reqData+ "&sign=" + reqSign;
        }
        return url;
    }
}
